/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author YDZ
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadFileParams } from '/#/axios';
import { UploadApiResult } from '../sys/upload';

const { ctxPath, adminPath } = useGlobSetting();

export interface PuVmiBillVouch extends BasicModel<PuVmiBillVouch> {
  djno?: string; // 单据号
  pkCorp?: string; // 公司主键
  venId?: string; // 供应商ID
  ddate?: string; // 单据日期
  itaxmoney?: number; // 价税合计
  itax?: number; // 税额
  imoney?: number; // 无税金额
  prtQty?: number; // 打印次数
  puVmiBillVouchsList?: any[]; // 子表列表
}

export const puVmiBillVouchList = (params?: PuVmiBillVouch | any) =>
  defHttp.get<PuVmiBillVouch>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/list',
    params,
  });

export const puVmiBillVouchListData = (params?: PuVmiBillVouch | any) =>
  defHttp.post<Page<PuVmiBillVouch>>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/listData',
    params,
  });

export const puVmiBillVouchForm = (params?: PuVmiBillVouch | any) =>
  defHttp.get<PuVmiBillVouch>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/form',
    params,
  });

export const puVmiBillVouchSave = (params?: any, data?: PuVmiBillVouch | any) =>
  defHttp.postJson<PuVmiBillVouch>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/save',
    params,
    data,
  });

export const puVmiBillVouchDelete = (params?: PuVmiBillVouch | any) =>
  defHttp.get<PuVmiBillVouch>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/delete',
    params,
  });

// /srm/cw/billvouch/puBillVouch/vmi/invoiceRecords 查询指定单据已上传的发票记录
export const puVmiBillVouchInvoiceRecords = (params?: PuVmiBillVouch | any) =>
  defHttp.get<PuVmiBillVouch>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/invoiceRecords',
    params,
  });

// /srm/cw/billvouch/puBillVouch/vmi/invoice  发票上传识别

export const puBillVouchInvoice = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
  cancelToken?: any,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/srm/cw/billvouch/puBillVouch/vmi/invoice',
      onUploadProgress,
      cancelToken,
    },
    params,
  );
// /srm/cw/billvouch/puBillVouch/vmi/deleteInvoice 删除指定的发票 
export const puVmiBillVouchDeleteInvoice = (params?: PuVmiBillVouch | any) =>
  defHttp.post<Page<PuVmiBillVouch>>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/deleteInvoice',
    params,
  });
// /srm/cw/billvouch/puBillVouch/vmi/verifyInvoice 验证上传的发票数总金额是否匹配
export const puVmiBillVouchVerifyInvoice = (params?: PuVmiBillVouch | any) =>
  defHttp.post<Page<PuVmiBillVouch>>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/verifyInvoice',
    params,
  });

// /srm/cw/billvouch/puBillVouch/vmi/execMatch 执行数据对比
export const puVmiBillVouchExecMatch = (params?: PuVmiBillVouch | any) =>
  defHttp.post<Page<PuVmiBillVouch>>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/execMatch',
    params,
  });

// /srm/cw/billvouch/puBillVouch/vmi/tempSave 暂存结果
export const puVmiBillVouchTempSave = (params?: PuVmiBillVouch | any) =>
  defHttp.postJson<PuVmiBillVouch>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/tempSave',
    params,
  });

// /srm/cw/billvouch/puBillVouch/vmi/submit 暂存结果
export const puVmiBillVouchSubmit = (params?: PuVmiBillVouch | any) =>
  defHttp.postJson<PuVmiBillVouch>({
    url: adminPath + '/srm/cw/billvouch/puBillVouch/vmi/submit',
    params,
  });
